package com.world.config;

import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.CorsRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * web配置
 *
 * @author WangYX
 * @version 1.0.0
 * @date 2023/06/02 15:38
 */
@Configuration
public class WebConfig implements WebMvcConfigurer {

    /**
     * 开启全局跨域
     *
     * @param registry CorsRegistry
     * @author WangYX
     * @date 2023/08/29 12:25
     */
    @Override
    public void addCorsMappings(CorsRegistry registry) {
        //添加映射路径
        registry.addMapping("/**")
                //放行哪些原始域
                .allowedOriginPatterns("*")
                //是否发送Cookie信息
                .allowCredentials(true)
                //放行哪些原始域(请求方式)
                .allowedMethods("GET", "POST", "PUT", "DELETE")
                //放行哪些原始域(头部信息)
                .allowedHeaders("*");
    }


}
